home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / a_utils / decomp.lha / decomp / READMETHREE < prev    next >
Text File  |  1989-10-03  |  5KB  |  159 lines

  1.  
  2. Return-Path: reuter%cookie.DEC@decwrl.dec.com
  3. Received: by june.cs.washington.edu (5.52.1/6.11)
  4.     id AA11965; Thu, 14 Jan 88 08:33:32 PST
  5. Received: by decwrl.dec.com (5.54.4/4.7.34)
  6.     id AA21398; Thu, 14 Jan 88 08:33:06 PST
  7. Date: Thu, 14 Jan 88 08:33:06 PST
  8. Message-Id: <8801141633.AA21398@decwrl.dec.com>
  9. From: reuter%cookie.DEC@decwrl.dec.com (Chocolate helps prevent cavities!)
  10. To: pardo@june.cs.washington.edu
  11. Subject: decomp fixes
  12.  
  13. Goodness.  Believe it or not, I never tried decompiling a linked
  14. C program.  I only worked with object modules.
  15.  
  16. The problem is that the decompiler does not recognize the "exit" system
  17. call as a basic block terminator.  This would have been just fine if
  18. the exception handling cases had been written correctly, but they
  19. weren't.  Here are the fixes to the exception code, supplied as
  20. "diff -c" output for the modules "blocks.c" and "nodes.c".
  21.  
  22.     Jim
  23.  
  24. *** blocks.c.old    Wed Jan 13 12:40:46 1988
  25. --- blocks.c    Wed Jan 13 12:43:37 1988
  26. ***************
  27. *** 14,19
  28.   #include "objfile.h"
  29.   #include "vartab.h"
  30.   #include "nodes.h"
  31.   
  32.   static int op_argval[6];
  33.   
  34.  
  35. --- 14,20 -----
  36.   #include "objfile.h"
  37.   #include "vartab.h"
  38.   #include "nodes.h"
  39. + #include <setjmp.h>
  40.   
  41. + extern jmp_buf badbranch;
  42.   static int op_argval[6];
  43.   
  44. ***************
  45. *** 294,300
  46.       }
  47.       }
  48.       /* no more code in function */
  49. !     if ( cur_address > node_entry )
  50.       fprintf( stderr, "Dangling function end\n" );
  51.   }
  52.   
  53.  
  54. --- 297,303 -----
  55.       }
  56.       }
  57.       /* no more code in function */
  58. !     if ( cur_address > node_entry ) {
  59.       fprintf( stderr, "Dangling function end\n" );
  60. +      longjmp( badbranch, 1 );
  61. +     }
  62.   }
  63.  
  64.  
  65.  
  66. *** nodes.c.old    Wed Jan 13 12:41:03 1988
  67. --- nodes.c    Wed Jan 13 12:35:59 1988
  68. ***************
  69. *** 79,84
  70.       register struct node *n;
  71.       register int i, j;
  72.   
  73.       node_max = node_count * 4;
  74.       node_array = (struct node **) malloc( node_max * sizeof( struct node * ) );
  75.       if ( node_array == NULL ) {
  76.  
  77. --- 79,89 -----
  78.       register struct node *n;
  79.       register int i, j;
  80.   
  81. +     if ( node_count <= 0 ) {
  82. +     fprintf( stderr, "Bad node_count in array_nodes()\n" );
  83. +     longjmp( badbranch, 1 );
  84. +     }
  85.       node_max = node_count * 4;
  86.       node_array = (struct node **) malloc( node_max * sizeof( struct node * ) );
  87.       if ( node_array == NULL ) {
  88.  
  89.  
  90.  
  91.  
  92. Return-Path: ucsd!spsd!felix!art@beaver
  93. Received: from beaver.cs.washington.edu by june.cs.washington.edu (5.61/7.0j)
  94.     id AA22653; Mon, 2 Oct 89 12:27:47 -0700
  95. Received: by beaver.cs.washington.edu (5.61/7.0)
  96.     id AA19694; Mon, 2 Oct 89 12:27:37 -0700
  97. Received: from spsd.UUCP by ucsd.edu; id AA26715
  98.     sendmail 5.61/UCSD-2.0-sun via UUCP
  99.     Mon, 2 Oct 89 11:45:39 -0700 for june.cs.washington.edu!pardo
  100. Received: by spsd.CEO.DG.COM (smail2.5)
  101.     id AA21848; 30 Sep 89 11:49:07 PDT (Sat)
  102. Received: from fritz.UUCP (fritz.ARPA) by felix.UUCP (4.12/5.17)
  103.     id AA22718; Sat, 30 Sep 89 07:27:59 pdt
  104. Received: by fritz.UUCP (1.2/5.17)
  105.     id AA03974; Sat, 30 Sep 89 07:26:42 pdt
  106. From: ucsd!felix!art@beaver (Art Dederick)
  107. Message-Id: <8909301426.AA03974@fritz.UUCP>
  108. To: spsd!ucsd!uw-beaver!june.cs.washington.edu!pardo@beaver
  109. Subject: Re: decomp, #2
  110. Date: Sat, 30 Sep 89 07:26:41 PDT
  111.  
  112. Second try on this message, not sure you got the first attempt.
  113. Send me an ACK if you get either message.  Thanks.
  114.  
  115. Found the segmentation bug.  I was very stupid and didn't save the
  116. original code so I can't make diffs, sorry about that.  The fix was
  117. easy, just add the following code to the beginning of free_nodes():
  118.  
  119.     if (node_count && node_array == NULL) {
  120.     fprintf(stderr, "free_nodes: node_count > 0 && node_array == NULL\n");
  121.         return;
  122.     }
  123.  
  124. I don't know why the node count would be non-zero but the node array
  125. by empty.  You could probably explain it (hint hint :-).
  126.  
  127. In addition, I added code to remove .o file usage from an a.out file.
  128. I kept getting function names like foo.o() instead of main().  Add the
  129. following code to decomp():
  130.  
  131.     for (i = 0; i < nsym / sizeof(struct nlist); i++) {
  132.     if ( ((symtab+i)->n_type & ~1) == 4 ) {
  133. |        char *p, *rindex();
  134. |
  135. |        p = rindex(&strtab[(symtab+i)->n_un.n_strx], 'o');
  136. |        if (!p || p[-1] != '.')
  137.         glb_add( (symtab+i)->n_value, i, 1 - ((symtab+i)->n_type & 1) );
  138.     }
  139.     }
  140.  
  141. This code will skip all entries in the symbol table that have a ".o"
  142. suffix.
  143.  
  144. Another area I am currently trying to improve is function calling
  145. labels when decompiling a.out files.  Currently only when a .o file is
  146. decompiled will references to functions use the name of the function.
  147. What I am attempting to do is search for the functions address in the
  148. symbol table when a call is made and use the name instead of the
  149. 'Gnnnn' label.  So far I'm stumped.
  150.  
  151.        __              __
  152.       /  )    _/_     /  )      /             /
  153.      /--/ __  /      /  / _  __/ _  __  o _. /_ 
  154.     /  (_/ (_<__    /__/_</_(_/_</_/ (_<_(__/ <_
  155.  
  156.     felix!art    (714)966-3618
  157.